package com.feng.cloud.common.interceptor;

import com.feng.cloud.common.configure.properties.GatewayTokenProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName ServerProtectConfigure
 * @Description 服务保护
 * @Author Better Feng
 * @Date 2020/1/6 9:50
 * @Version 1.0
 **/
@Configuration
public class FengWebMvcConfigurer implements WebMvcConfigurer {

    @Autowired
    private GatewayTokenProperties gatewayTokenProperties;

    @Bean
    public HandlerInterceptor serverProtectInterceptor() {
        return new ServerProtectInterceptor(gatewayTokenProperties);
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(serverProtectInterceptor());
    }
}
